/**
 * 
 */
package com.xbang.attendance.web.action.warehouse.warn;

import org.springframework.beans.factory.annotation.Autowired;

import com.xbang.attendance.entity.stock.InventoryWarningRecord;
import com.xbang.attendance.service.WarehouseService;
import com.demo2do.lighturl.annotation.Action;
import com.xbang.core.struts.support.BaseActionSupport;

/**
 * @author dev.zhang
 * 
 */
public class View extends BaseActionSupport {

	private static final long serialVersionUID = 4793296582317707612L;

	@Autowired
	private WarehouseService warehouseService;

	private Integer inventoryWarningRecordId;

	private boolean operationResult;

	/**
	 * 增加库存信息跳转Action
	 * 
	 * @return
	 * @throws Exception
	 */
	@Action("/house/housewaring/view/do")
	public String doView() throws Exception {
		return "index";
	}

	@Action("/house/housewaring/sendmail/${inventoryWarningRecordId}")
	public String sendMail() throws Exception {

		operationResult = false;

		if (null != inventoryWarningRecordId) {
			InventoryWarningRecord inventoryWarningRecord = (InventoryWarningRecord) warehouseService.get(InventoryWarningRecord.class,
					inventoryWarningRecordId);
			if (inventoryWarningRecord != null) {
				warehouseService.sendWarehouseWarnMail(inventoryWarningRecord);
				operationResult = true;
			}
		}

		return "j:operationResult";
	}

	/**
	 * @return the inventoryWarningRecordId
	 */
	public Integer getInventoryWarningRecordId() {
		return inventoryWarningRecordId;
	}

	/**
	 * @param inventoryWarningRecordId
	 *            the inventoryWarningRecordId to set
	 */
	public void setInventoryWarningRecordId(Integer inventoryWarningRecordId) {
		this.inventoryWarningRecordId = inventoryWarningRecordId;
	}

	/**
	 * @return the operationResult
	 */
	public boolean isOperationResult() {
		return operationResult;
	}

	/**
	 * @param operationResult
	 *            the operationResult to set
	 */
	public void setOperationResult(boolean operationResult) {
		this.operationResult = operationResult;
	}

}
